feat: local version history — automatic snapshots, diff & restore#10
Merged
Conversation
Automatic IndexedDB snapshots of every workspace file (first save / 3-min interval / 400-char delta), a History panel (sidebar right-click) with a hand-rolled LCS line diff vs the current document, one-click restore with a pre-restore safety snapshot, and Copy-to-clipboard. Zero new dependencies. Hardened per adversarial multi-agent review (9 confirmed findings fixed): - meta/content split in IDB so listing & pruning never deserialize bodies - per-file byte budget (25MB) + count caps (50/file, 400 global) + >5MB skip - diff rendering collapses unchanged runs to 3-line context and caps rows, preventing DOM blowups on large documents - restore reads the AUTHORITATIVE current content (disk / single-linked file, not the localStorage cache) for diffs and safety snapshots - restore reports honestly: quota failures show an error, never a false success toast - deleting a file purges its history (no sensitive retention, no orphan eviction of live history) Tests: 9-test Playwright spec (API, IDB storage, diff correctness, panel, restore round-trip incl. safety snapshot, dedupe, purge); smoke green; visual verify at 1280x800. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Local version history — the classic must-have of serious editors, fully client-side. Snapshots of every workspace file are captured automatically as you edit and stored in an IndexedDB ring buffer; a History panel (right-click a file in the sidebar) shows a timeline with a GitHub-style line diff vs the current document, one-click Restore (with a pre-restore safety snapshot, so restores are undoable) and Copy.
Zero new dependencies — the line diff is ~90 lines of hand-rolled LCS with prefix/suffix trimming, matching the project's zero-dep ethos.
How it works
saveToLocalStorage(keystroke autosave) andsetFileContent(file-switch saves). All calls guarded — the app behaves identically if the module fails to load.textagent-history, split intometa(tiny records for listing/pruning) andcontent(loaded on demand).Hardened via adversarial multi-agent review (9 confirmed findings fixed pre-merge)
disk.readSingleFile), not the stale localStorage cache, for both the diff and the safety snapshotTesting
🤖 Generated with Claude Code